<!DOCTYPE html>
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php 
	//开启session
		session_start();
 if($_SESSION['user']==''){
	echo "<script>alert('请先登录！！');window.location.href='./login.php';</script>";
	exit;
} 
?>
<!-- saved from url=(0032)http://shopping.vancl.com/mycart -->

        <meta http-equiv="Content-Language" content="zh-CN">
      
        <title>购物车 - 大唐天宝</title>
    <link rel="Stylesheet" type="text/css" charset="utf-8" href="../public/stylesheet/other/order.css">        
    <link rel="stylesheet" type="text/css" charset="utf-8" href="../public/stylesheet/other/order_2.css">

    <link href="./css/popupdialog.css" type="text/css" rel="stylesheet" id="popuplogincss"></head>
    <body class="mycart">
        <div id="wrapper">
            <div id="header" class="clearfix">
                    <a class="logo" href="#" title="大唐天宝" target="_blank">
                        <img src="../public/images/logol1.png">
                    </a>
                    <div class="help-center">
                        <a href="http://help.vancl.com/" target="_blank">帮助中心</a>
                    </div>
                    <div class="account">
                            <p>您好，<?php echo $_SESSION['user']; ?><span class="username"></span><a class="logout" href="doaction.php?a=doLogout">退出登录</a>
                    </div>
            </div>
            <div id="location">
                
    <em>1.我的购物车</em> <span>2.填写核对信息单</span> <span>3.成功提交订单</span>

            </div>
            <div id="content">

    <div id="cart-gift">


    <div class="cart-top">
            <h2>
                我的购物车</h2>
            <span>(<a class="gwqd">选购清单</a>)</span>
    </div>
    <div class="tip">
        <span>温馨提示：</span>1.选购清单中的商品无法保留库存，请您及时结算。2.商品的价格和库存将以订单提交时为准。3.促销活动满减优惠将均摊至商品小计中。
    </div>
	
	<?php
		//导入配置文件
			include('../public/config.php');
		//接收传递过来的id与数量
			$id=$_GET['goodsid'];
			if(!empty($id)&&!empty($_POST['number'])){
			$_SESSION['shop'][$id]=$_POST['number'];
			}else{
				echo "<script>alert('您还没有向购物车添加商品哦~~~~');window.location.href='./index.php';</script>";
				exit;
			}
	
		//取出键值
			$keystr=array_keys($_SESSION['shop']);
			$idstr=implode(',',$keystr);
			//var_dump($idstr);
		//设置图片路径
			$path="../public/uploads/";
		//连接数据库
			$con=@mysql_connect(HOST,USER,PASS) or die("连接数据库失败！！！");
		//选择数据库并设置字符集
			mysql_select_db(DBNAME,$con);
			mysql_set_charset('utf8');
			
	?>	
<div id="cart">
</div>
    <div id="cart-product" class="clearfix">
        <div id="batchdelcart">
            <table cellspacing="0">
                <thead>
                    <tr>
                        <th class="title-white bd-left">&nbsp;
                            
                      </th>
                        <th class="bar-title ">
                            <input id="all-ckb-top" type="checkbox" class="track all-products-ckb ckb" name="all-products" value="all-products"><label for="all-ckb-top">全选</label>
                        </th>
                        <th class="image">&nbsp;
                            
                      </th>
                        <th class="name">
                            商品名称
                        </th>
                        <th class="size">
                            尺寸
                        </th>
                        <th class="presentpoints" style="display:none">
                            积分
                        </th>
                        <th class="price">
                            单价
                        </th>
                        <th class="qty">
                            数量
                        </th>
                        <th class="discount">
                            优惠
                        </th>
                        <th class="subtotal">
                            小计
                        </th>
                        <th class="operate ">
                            操作
                        </th>
                        <th class="title-white bd-right">&nbsp;
                            
                      </th>
                    </tr>
                </thead>
                    <tbody class="vancl-title">
                        <tr>
                            <td class="white bd-left">&nbsp;
                                
                          </td>
                            <td colspan="9" class="vancl-title-bottom">
                                <p class="vancl-title-left">
                                    <input id="vancl-ckb-top" type="checkbox" name="vancl-products" value="shippers">
                                    以下商品由大唐天宝负责配送
                                </p>
                                <div class="vancl-title-right pos-r">
                                    <p>
                                            您目前可享受全场购物免运费                                    </p>
                                </div>
                            </td>
                            <td class="white bd-right">&nbsp;
                                
                          </td>
                        </tr>
                    </tbody>
                    <tbody>
                        <tr>
                            <td class="white bd-left">&nbsp;
                                
                          </td>
                           
                        </tr>
                    </tbody>
					
                    <tbody id="vancl-general-product" name="vancl-general-product">
			<?php 
			//编写sql语句
				$sql = "select goods,picname,price,id from goods where id in ({$idstr})";
				//var_dump($sql);
			//执行sql语句，返回结果集
				$result = mysql_query($sql);
			//解析结果集，并遍历输出
				if(empty($result)){
						echo "";
				}else{
				while($row = mysql_fetch_assoc($result)){
			?>
                            <tr class="selected">
        <td class="white bd-left bd-bottom">&nbsp;
            
        </td>
        <td class="bar bd-bottom" rowspan="1">
            <input type="checkbox" class="track ckb" name="p-item" data-del-tip="" value="" checked="checked" issupplier="False" shopid="10258">
        </td>
        <td class="image bd-bottom" rowspan="1">
            <a target="_blank" href="#">
                <img  src="<?php echo $path.'s_'.$row['picname'];?>"></a>
        </td>
        <td class="name bd-bottom">
            <a target="_blank" href="#">
                <?php echo $row['goods'];?>
            </a>
        </td>
        <td class="size bd-bottom">
            <a target="_blank" title="XL">
                XL
            </a>
        </td>
        <td class="presentpoints bd-bottom" style="display:none">
            29分
        </td>
        <td class="price bd-bottom">
            ￥<?php echo $row['price']; ?>
        </td>
        <td class="qty bd-bottom">
            <form class="modify-qty" action="#" method="get">
                 <!--<a class="track decrease-disable" href="#"name="sp_cart_mycart_decrease">减少</a>-->
				 <a class="decrease track" href="#"name="sp_cart_mycart_decrease">减少</a>
				
                <input name="qty" type="text" class="modify-product-qty" value="<?php echo $_SESSION['shop'][$row['id']]; ?>" maxlength="3">
                <noscript>
                    &lt;input type="submit" class="nojs-btn" value="修改" /&gt;</noscript>
                <a class="increase track" href="#" name="sp_cart_mycart_increase">增加</a>
            <input name="product-qty" type="hidden" value="1">
            <input name="product-code" type="hidden" value="6194575">
            <input name="sku" type="hidden" value="15336418">
            <input name="ispoint" type="hidden" value="False">
            </form>
        </td>
        <td class="bd-bottom">
                -
        </td>
        <td class="subtotal bd-bottom">
            ￥<?php $subtotal=($row['price']*$_SESSION['shop'][$row['id']]);$total+=$subtotal; echo $subtotal;?>
        </td>
        <td class="operate bd-bottom">
            <a href="#" class="add-faverate track" name="sp_cart_mycart_addfaverate" title="移入收藏夹">收藏</a> <a class="del track" name="sp_cart_mycart_del" href="doaction.php?a=delshop&id=">
                                 删除</a>
        </td>
        <td class="white bd-right bd-bottom">&nbsp;
            
        </td>
    </tr>
			
		<?php } 
			}
		?>

                    </tbody>
                    <tbody id="vancl-point-product" name="vancl-point-product">
                        
                    </tbody>
                    <tbody id="vancl-present-product" name="vancl-present-product">
                        
                    </tbody>
                <tbody><tr>
                    <td class="white bd-left table-bottom table-bottom-td">&nbsp;
                        
                  </td>
                    <td colspan="9" class="table-bottom table-bottom-td">&nbsp;
                        <?php if(empty($_SESSION['shop'])){
							echo "您的购物车中还没有商品哦~~~";
						} ?>
                  </td>
                    <td class="white bd-right table-bottom table-bottom-td">&nbsp;
                        
                  </td>
                </tr>
            </tbody></table>
            <div class="bar-empty clearfix">
            </div>
            <div id="bar-summary" class="bar-summary clearfix" style="top: 0px;">
                <div class="bar">
                    <input id="all-ckb-bt" type="checkbox" name="all-products" value="all-products" class="track all-products-ckb ckb" data-del-tip=""><label for="all-ckb-bt">全选</label>
                    <a href="javascript:;" class="batch-del-cart track" name="sp_cart_mycar_batch_clear">
                        删除</a>                </div>
                <div class="summary">
              
                    产品金额总计(不含运费)：<span class="amount">￥<em>
					<?php $_SESSION['total']=$total; echo $total; ?></em></span>               				
					</div>
                <div class="btn-panel">
                     <a href="index.php" class="go-buy track" name="sp_cart_mycar_goBuy">
                    &lt;&lt;继续购物</a> <a class="checkout track" href="order.php" id="sp_cart_mycar_goPay" name="sp_cart_mycar_goPay">
                        去结算&gt;&gt;</a>                </div>
            </div>
        </div>
    </div>
 
</div>
    <div id="cart-collocate" style="top: 263.5px; left: 171.5px;">
        <div class="coudan-title" style="display: none;">
            <h2><strong>免运费凑单商品</strong>（您再买<span id="coudan-differ"></span>大唐发货商品，即可享免运费优惠）</h2>
            <a href="javascript:;" class="close"><img src="./images/dpbox_06.gif"></a>        </div>
        <div id="collocate-list" class="product-list-panel  coudan-content  clearfix clearfixCD" style="display: none;">        </div>
    </div>

<div id="remove-product" style="display: none;">
    <table cellspacing="0">
        <thead>
            <tr>
                <th scope="col" colspan="6">
                    您删除的商品，您可以 <span>重新购买</span> 或 <span>放入收藏夹</span>。
                </th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
</div>

<div id="gift" data-present-url="/mycart/presents">
    
</div>
 </div>
            <div id="footer">
                    <p class="copyrights">Copyright 2007 - 2015 vancl.com All Rights Reserved 京ICP证100557号 京公网安备11010102000579号 出版物经营许可证新出发京批字第直110138号</p>
                    <p class="certs">
                        <a class="ectrustprc" title="中国电子商务诚信单位" href="http://www.ectrustprc.org.cn/seal/splash/1000020.htm" target="_blank">
                            <img alt="中国电子商务诚信单位" src="./images/cert-redlogo.gif">
                        </a>
                        <span class="costumeorg" title="中国服装协会会员单位">
                            <img alt="中国服装协会会员单位" src="./购物车 - VANCL 凡客诚品_files/cert-costumeorg.gif">
                        </span>
                        <a class="online315" href="http://www.315online.com.cn/member/315090053.html" title="网上交易保障中心" target="_blank">
                            <img alt="网上交易保障中心" src="./images/cert-wsjybzzx.gif">
                        </a>
                    </p>
            </div>
        </div>       
        
       </body></html>
	   <?php //关闭数据库并销毁结果集
			mysql_close($con);
			mysql_free_result($result);
		?>